package mo.golden;

public class L01_07 {

    public void rotate(int[][] matrix) {
        int n = matrix.length;
        int i = 0, j = n - 1;

        while (i < j) {
            int[] tmp = matrix[i];
            matrix[i] = matrix[j];
            matrix[j] = tmp;
            i++;
            j--;
        }

        for (int k = 0; k < n; k++) {
            for (int l = 0; l <= k-1; l++) {
                int tmp = matrix[k][l];
                matrix[k][l] = matrix[l][k];
                matrix[l][k] = tmp;
            }
        }
    }

}
